package com.example.zzhxiangmu.model.utils

import com.example.zzhxiangmu.model.api.Apiservsi
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit

class Httpwang private constructor(){
    companion object{
        val httpwang:Httpwang by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){

            Httpwang()
        }
    }

    val retrofit=Retrofit.Builder()
        .addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .baseUrl("http://10.59.9.24/")
        .client(OkHttpClient.Builder()
            .addInterceptor(HttpLoggingInterceptor().apply {
                level=HttpLoggingInterceptor.Level.BODY

            })
            .readTimeout(3,TimeUnit.SECONDS)
            .connectTimeout(3,TimeUnit.SECONDS)
            .build()

        ).build()

        val apiservsi=retrofit.create<Apiservsi>()

}